package com.tust.app.service.impl;


import com.tust.app.dao.AnswerMapper;
import com.tust.app.domain.Answer;
import com.tust.app.service.AnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnswerServiceImpl implements AnswerService {

    @Autowired
    private AnswerMapper answerMapper;

    @Override
    public Answer getAnswerById(Integer id) {
        return answerMapper.selectAnswerById(id);
    }

    @Override
    public List<Answer> getAllAnswers() {
        return answerMapper.selectAllAnswers();
    }

    @Override
    public void addAnswer(Answer answer) {
        answerMapper.insertAnswer(answer);
    }

    @Override
    public void updateAnswer(Answer answer) {
        answerMapper.updateAnswer(answer);
    }

    @Override
    public boolean deleteAnswer(Integer id) {
        return answerMapper.deleteAnswer(id);
    }

    @Override
    public List<Answer> getAnswersByState(Integer state2) {
        return answerMapper.selectAnswersByState(state2); // 新增方法
    }
}